<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
$ui = new UI();
include( "member/news.php" );
$conf = new Config();
if ( $conf->get( "calcbet" ) == 1 )
{
    $ui->showErrorPage( "<p class=error>颁奖过帐中，请稍後再使用本功能！</p>" );
    exit();
}
$sql = "select sum(amount),sum(a5),sum(b5),count(amount) from bet2 where lotto_id in (".$lottos.") and user_id=".$userid." and rame in (0,9)";
if ( getvar( "bettype" ) != "" )
{
    $sql .= " and bettype=".getvar( "bettype" );
}
$rst = getdb( $sql );
if ( !$rst->eof )
{
    $total = $rst->f[0];
    $backtot = $rst->f[1];
    $wintot = $rst->f[2];
    $items = $rst->f[3];
    $sql = "select * from bet2 where lotto_id in (".$lottos.") and user_id=".$userid;
    if ( getvar( "bettype" ) != "" )
    {
        $sql .= " and bettype=".getvar( "bettype" );
    }
    $sql .= " order by createtime desc,bettype,numbers";
    $page = isset( $_GET['page'] ) ? intval( $_GET['page'] ) : 1;
    if ( $page == 0 )
    {
        $page = 1;
    }
    $pagesize = 15;
    $rst = getdb( $sql, $page, $pagesize );
    $movenext = !$rst->eof;
    if ( $movenext )
    {
        echo "<br>";
        echo title( "大股东 走飞清单", "", 620 );
        echo "<br>";
        echo "<table width=620 border=1 cellpadding=3 cellspacing=0>";
        echo "<tr class=td5 align=center><td nowrap>序号 / 时间<td nowrap>期数 / 开奖日期<td nowrap>走飞内容<td nowrap>赔率<td nowrap>走飞金额<td nowrap>退水<td nowrap>结果<td nowrap>备注";
        $tot = 0;
        $win = 0;
        $back = 0;
        $item = 0;
        while ( $movenext )
        {
            ++$item;
            echo "<tr align=right class=td2 onmouseover=msover() onmouseout=msout() valign=top>";
            echo "<td nowrap><font color=#217952>".$rst->f['id']."</font> &nbsp; ".date( "m-d H:i:s", $rst->f['createtime'] );
            $lotto = get_lotto( $rst->f['lotto_id'] );
            echo "<td nowrap>".d3( $lotto->data['round'] )." 期 <font color=#217952>".$lotto->data['open']."</font>";
            echo "<td nowrap>".GetBetContent( $rst->f['bettype'], $rst->f['numbers'], $rst->f['amount'] );
            echo "<td nowrap>".$rst->f['rate'];
            echo "<td nowrap>".$rst->f['amount'];
            echo "<td nowrap>".say_numbercolor( $rst->f['a5'] );
            echo "<td nowrap>".say_numbercolor( $rst->f['c5'] );
            $reme = "";
            if ( $rst->f['rame'] == 1 )
            {
                $reme = "逾时";
            }
            if ( $rst->f['rame'] == 2 )
            {
                $reme = "取消";
            }
            if ( $rst->f['rame'] == 3 )
            {
                $reme = "异常";
            }
            if ( $rst->f['betmode'] == 1 )
            {
                $reme .= "#";
            }
            echo "<td><font color='red'>".$reme."</font>";
            if ( $rst->f['rame'] != 2 )
            {
                $tot += $rst->f['amount'];
                $back += $rst->f['a5'];
                $win += $rst->f['b5'];
            }
            $rst->movenext();
            $movenext = !$rst->eof;
        }
        if ( 15 < $items )
        {
            echo "<tr class=td6><td colspan=4 align=right nowrap><b>小计 ".$item." 笔</b>";
            echo "<td align=right nowrap><b>".$tot."</b>";
            echo "<td align=right nowrap><b>".say_numbercolor( $back )."</b>";
            echo "<td align=right nowrap><b>".say_numbercolor( $win )."</b><td>";
        }
        echo "<tr class=td5><td colspan=4 align=right><b>合计 ".$items." 笔</b>";
        echo "<td align=right nowrap><b>".$total."</b>";
        echo "<td align=right nowrap><b>".say_numbercolor( $backtot )."</b>";
        echo "<td align=right nowrap><b>".say_numbercolor( $wintot )."</b><td>";
        echo "<tr><td class=td0 colspan=10>".$rst->pagelink( )."</td></tr>";
        echo "<tr class=td3 align=right><td colspan=6><b>大股东结果 (总计)</b>";
        echo "<td><b>".say_numbercolor( $c4 + $d8 - $wintot )."</b><td>";
        echo "<tr class=td3 align=right><td colspan=6><b>公司结果 (总计)</b>";
        echo "<td><b>".say_numbercolor( $d4 + $wintot )."</b><td>";
        echo "</td></tr>";
        echo "</table>";
    }
}
$ui->footer();
?>